package com.xxd.spring.boot.demo.wubolin.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.xxd.spring.boot.demo.wubolin.entity.Classes;
import com.xxd.spring.boot.demo.wubolin.mapper.ClassesMapper;
import com.xxd.spring.boot.demo.wubolin.service.ClassesService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;
import java.util.Map;

@Service
public class ClassesServiceImpl implements ClassesService {
    @Autowired
    private ClassesMapper classesMapper;

    @Override
    public int add(Classes classes) {
        return classesMapper.insert(classes);
    }

    @Override
    public int update(Classes classes) {
        return classesMapper.updateById(classes);
    }

    @Override
    public int delete(Integer id) {
        return classesMapper.deleteById(id);
    }

    @Override
    public IPage<Classes> listPage(Page page, Map<String, Object> params) {
        QueryWrapper queryWrapper = new QueryWrapper();
        queryWrapper.setEntity(params);
        return classesMapper.selectPage(page,queryWrapper);
    }

    @Override
    public List<Classes> list(Map<String, Object> params) {
        QueryWrapper queryWrapper = new QueryWrapper();
        queryWrapper.setEntity(params);
        return classesMapper.selectList(queryWrapper);
    }

    @Override
    public Classes infoById(Integer id) {
        return classesMapper.infoById(id);
    }

    @Override
    public List<Classes> all() {
        return classesMapper.all();
    }
}
